#!/usr/bin/bash

tel=(
电话号码
)

msg=$(echo "美联存储3小时无数据，登陆10.149.212.96:/glomedia/meilian/video/查看" | iconv -f utf8 -t gbk )
msg2=$(echo "美联存储2小时内有0kb文件，登陆10.149.212.96:/glomedia/meilian/video/查看" | iconv -f utf8 -t gbk )

dir="/glomedia/meilian/video/"

#if ! pgrep inotifywait 
#then 
#    bash  /opt/monitor/start_inotifywait_meilian.sh $dir
#else
#    ps -ef | grep inotifywait
#fi

#if [ -f /tmp/get_file_msg ]
#then
#    last_get=$(stat -c %Y /tmp/get_file_msg)
#else
#    last_get=0
#fi

if [ -f /tmp/send_msg_time_meilian ] 
then 
    last_send=$(cat /tmp/send_msg_time_meilian)
else
    last_send=0
fi

now=$(date +%s)

rst=$(find $dir -type f -mmin -180 | wc -l)



if (( rst==0 && now-last_send>=1800 ))
then
    for i in ${tel[@]}
    do
        curl "http://短信网关?OperID=xxxx&OperPass=****&DesMobile=${i}&Content=${msg}&ContentType=8"
    done
    date +%s > /tmp/send_msg_time_meilian
fi


#is_empty=$(find $dir -type f -mmin -120 -empty | wc -l )

#if (( is_empty != 0 && now-last_send>=1800 ))
#then
#    for i in ${tel[@]}
#    do
#        curl "http://短信网关?OperID=xxxx&OperPass=****&DesMobile=${i}&Content=${msg2}&ContentType=8"
#    done
#    date +%s > /tmp/send_msg_time_meilian
#fi
